from nonebot.plugin.on import on_regex
from nonebot.typing import T_State
from nonebot.adapters.onebot.v11 import GroupMessageEvent, Bot, MessageSegment
import requests


ecyt = on_regex(pattern=r"^二次元图$")


@ecyt.handle()
async def sj(bot: Bot, event: GroupMessageEvent, state: T_State):
    msg = await get_ecyt()
    # at_ = f"[CQ:at,qq={event.get_user_id()}]"
    await ecyt.send(MessageSegment.image(msg))


async def get_ecyt():
    url = 'https://api.lklblog.cn/api/ecy.php'
    get_data = requests.get(url)
    img = get_data.text.strip()
    return img
